.\" $OpenBSD: X509V3_EXT_get_nid.3,v 1.4 2024/05/14 06:57:10 tb Exp $
.\"
.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: May 14 2024 $
.Dt X509V3_EXT_GET_NID 3
.Os
.Sh NAME
.Nm X509V3_EXT_get_nid ,
.Nm X509V3_EXT_get
.Nd retrieve X.509v3 certificate extension methods
.Sh SYNOPSIS
.In openssl/x509v3.h
.Ft const X509V3_EXT_METHOD *
.Fo X509V3_EXT_get_nid
.Fa "int nid"
.Fc
.Ft const X509V3_EXT_METHOD *
.Fo X509V3_EXT_get
.Fa "X509_EXTENSION *ext"
.Fc
.Sh DESCRIPTION
An X.509v3 certificate extension contains an Object Identifier (OID),
a boolean criticality indicator, and an opaque extension value
.Po
an
.Vt ASN1_OCTET_STRING
.Pc
whose meaning is determined by the OID.
The library's
.Vt X509V3_EXT_METHOD
type,
which is not yet documented in detail,
contains a numeric identifier to represent the OID and various
handlers for encoding, decoding, printing, and configuring the
extension's value.
Criticality is handled separately, for example as an argument to
.Xr X509V3_add1_i2d 3 .
.Sh RETURN VALUES
.Fn X509V3_EXT_get_nid
returns the
.Vt X509V3_EXT_METHOD
corresponding to the numeric identifier
.Fa nid ,
or
.Dv NULL
if there is none.
.Pp
.Fn X509V3_EXT_get
returns the
.Vt X509V3_EXT_METHOD
associated with the extension type of
.Fa ext ,
or
.Dv NULL
if there is none.
.Sh SEE ALSO
.Xr i2s_ASN1_ENUMERATED_TABLE 3 ,
.Xr OBJ_create 3 ,
.Xr X509_EXTENSION_get_object 3 ,
.Xr X509V3_get_d2i 3
.Sh STANDARDS
RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
Certificate Revocation List (CRL) Profile
.Bl -dash -compact
.It
section 4.2: Certificate Extensions
.El
.Sh HISTORY
These functions first appeared in OpenSSL 0.9.2b and
have been available since
.Ox 2.6 .
.Sh CAVEATS
LibreSSL only supports built-in extension methods.
Other implementations have incomplete support for custom extension methods,
whose API is not threadsafe, does not affect the behavior of
.Xr X509_verify_cert 3 ,
and has various other surprising quirks.
Both functions prefer built-in methods over custom methods with the same OID.
